<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>登陆页面</title>
    <style>
        li {
            list-style: none;
            margin-top: 15px;
        }
    </style>
</head>

<body>
    <ul>
        <h2>LOGIN</h2>
        <form id="login_form">
            <li>
                <label for="">还没有帐号?</label>
                <a href="{:url('index/register','','')}">马上注册</a>
            </li>
            <li>
                <label>已有帐号，马上登陆</label>
            </li>
            <li>
                <label for="">手机号码</label>
                <input type="text" name="phone">
            </li>
            <li>
                <label for="">登陆密码</label>
                <input type="password" name="password">
            </li>
            <li>
                <input type="submit" name="" id="login" value="登陆>">
            </li>
        </form>
    </ul>
    <script src="__STATIC__/js/jquery-3.4.1.js"></script>
    <script>
        $(function() {
            //为登陆按钮绑定事件
            $('#login').on('click', function(e) {
                //禁止对象的冒泡事件
                e.preventDefault();
                //通过ajax传输数据
                $.ajax({
                    type: "post", //传输方式
                    url: "{:url('index/login_do','','')}", //传输那个方法
                    data: $('#login_form').serialize(), //要传输的表单，并且把表单序列化
                    success: function(result) { //回调函数
                        if (result.code == 1) {
                            alert(result.msg);
                            window.location.href = result.data;
                        } else {
                            alert(result.msg);
                        }
                    }
                });
            });
        });
    </script>
</body>

</html>